package com.bosssoft.hr.train.j2se.pojo.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.Objects;
import java.util.Set;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class User extends BaseEntity{
    /**
     * 编号
     */
    private String code;
    /**
     * 密码
     */
    private String password;
    /**
     * 姓名
     */
    private String name;
    /**
     * 头像
     */
    private String profilePicture;
    /**
     * 性别
     */
    private byte sex;
    /**
     * 生日
     */
    private Date birthday;
    /**
     *  电话号码
     */
    private String tel;
    /**
     *  邮箱
     */
    private String email;
    /**
     *  其他
     */
    private String other;
    /**
     * 备注
     */
    private String remark;
    /**
     * 部门id
     */
    private Long departmentId;
    /**
     * 职位id
     */
    private Long positionId;
    /**
     * 用户所拥有的多个角色
     */
    private Set<Role> roles;
    public User(Long id,String code,String name){
        this.id = id;
        this.code = code;
        this.name = name;
    }

    public User(Long id, Long tenantId, Long orgId, Long companyId, Long createdBy, String creator, Date createdTime, Long updatedBy, String modifier, Date updatedTime, byte status, Long version, String code, String password, String name, String profilePicture, byte sex, Date birthday, String tel, String email, String other, String remark, Long departmentId, Long positionId, Set<Role> roles) {
        super(id, tenantId, orgId, companyId, createdBy, creator, createdTime, updatedBy, modifier, updatedTime, status, version);
        this.code = code;
        this.password = password;
        this.name = name;
        this.profilePicture = profilePicture;
        this.sex = sex;
        this.birthday = birthday;
        this.tel = tel;
        this.email = email;
        this.other = other;
        this.remark = remark;
        this.departmentId = departmentId;
        this.positionId = positionId;
        this.roles = roles;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof User)) return false;
        if (!super.equals(o)) return false;
        User user = (User) o;
        return sex == user.sex && Objects.equals(code, user.code) && Objects.equals(password, user.password) && Objects.equals(name, user.name) && Objects.equals(profilePicture, user.profilePicture) && Objects.equals(birthday, user.birthday) && Objects.equals(tel, user.tel) && Objects.equals(email, user.email) && Objects.equals(other, user.other) && Objects.equals(remark, user.remark) && Objects.equals(departmentId, user.departmentId) && Objects.equals(positionId, user.positionId) && Objects.equals(roles, user.roles);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), code, password, name, profilePicture, sex, birthday, tel, email, other, remark, departmentId, positionId, roles);
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", code='" + code + '\'' +
                ", name='" + name + '\'' +
                '}';
    }
}
